#include <stdio.h>
#include <stdlib.h>

#define OUT_file "tarantulaOutput.out"

int main() 
{
	int totalpassed = 0;
	int totalfailed = 0; 
	int j;
	int h;
	int failed[1000];
       	int passed[1000];// assume fail and success should be 50/50

	FILE *open;
	char open_file[] = "dominion.c.gcov";
	open = fopen(open_file,"g");
	if( open == -1)
	{
		printf("Cannot open file");
		exit(1);
	}
	//Read through and count up our variables for suspiciousness
	char* code = malloc(sizeof(char) * 3000000); // more than enough space
	char* line_space = malloc(sizeof(char) * 500); 
	read(open,code,500);
	line = strtok(code, "\n"); // token 
	for(i = 0; i !=1000; i++)
	{
		failed[i] = 0;
		passed[i] = 0;
	}
	// open, reads, code pass or failed for suspecious equation count
	while( line_space !=NULL)
	{
		if(!strcmp(line_space, "Success"))
		{
			++totalpassed;
			j = 0 // pass
		}
		else if(!strcmp(line_space, "Failed"))
		{
			++totalfailed;
			j = 1 // failed 
		}
		else
			break; // EOF
		for( i = 1; i!=1000; i++)
		{
			if(line[ 9 - 1] ! = '#' && line[ 9 - 1] != '-') // 9 spaces in check for gcov # for bug or not
			{
				if(j) // failed since 
					++failed[i];
				else
					++passed[i];
			}
			line = strtok(NULL, "\n");
		}
	}
	// equate suspiciousness
	double susp = 0;
	for( i = 1; i !=1000; ++i)
		if(susp = ((failed[i] / (double) totafailed) + (passed[i] / (double) totalpassed))) ! = 0.0
		{
			printf("Line #%d is suspicious \n",i);
		}
	return 0;
}
